<?php
 /*******************************************************************************
 * @filename: index.ctp
 *
 * @author: immer_baldos
 *
 * @description: orders/index view
 *
 * @history:
 *
 *   VERSION   DATE                   BY          NOTES
 *  ---------------------------------------------------------------
 *     1.0     September  9, 2009     immer       initial bake
 *
 ******************************************************************************/
 ?>
 <div class="orders index">
<h2><?php __('Orders');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort('order_number');?></th>
	<th><?php echo $paginator->sort('print_count');?></th>
	<th><?php echo $paginator->sort('created');?></th>
	<th><?php echo $paginator->sort('print_date');?></th>
	<th><?php echo $paginator->sort('created_by');?></th>
	<th><?php echo $paginator->sort('ship_via');?></th>
	<th><?php echo $paginator->sort('sales_terms');?></th>
	<th><?php echo $paginator->sort('sales_person');?></th>
	<th><?php echo $paginator->sort('delivery_date');?></th>
	<th><?php echo $paginator->sort('customer_id');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($orders as $order):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $order['Order']['order_number']; ?>
		</td>
		<td>
			<?php echo $order['Order']['print_count']; ?>
		</td>
		<td>
			<?php echo $order['Order']['created']; ?>
		</td>
		<td>
			<?php echo $order['Order']['print_date']; ?>
		</td>
		<td>
			<?php echo $order['Order']['created_by']; ?>
		</td>
		<td>
			<?php echo $order['Order']['ship_via']; ?>
		</td>
		<td>
			<?php echo $order['Order']['sales_terms']; ?>
		</td>
		<td>
			<?php echo $order['Order']['sales_person']; ?>
		</td>
		<td>
			<?php echo $order['Order']['delivery_date']; ?>
		</td>
		<td>
			<?php echo $order['Customer']['name']; ?>
		</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('action' => 'view', $order['Order']['id'])); ?>
			<?php if ($_SESSION['Auth']['User']['role'] == "finance" || $_SESSION['Auth']['User']['role'] == "admin"): ?>
			    <?php echo $html->link(__('Edit', true), array('action' => 'edit', $order['Order']['id'])); ?>
			<?php endif; ?>
			<?php if ($_SESSION['Auth']['User']['role'] == "admin"): ?>
			    <?php echo $html->link(__('Delete', true), array('action' => 'delete', $order['Order']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $order['Order']['id'])); ?>
			<?php endif; ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
<div class="actions">
	<ul>
	<?php if ($_SESSION['Auth']['User']['role'] == "finance" || $_SESSION['Auth']['User']['role'] == "admin"): ?>
		<li><?php echo $html->link(__('New Order', true), array('action' => 'add')); ?></li>
		<li><?php echo $html->link(__('List Customers', true), array('controller' => 'customers', 'action' => 'index')); ?> </li>
		<li><?php echo $html->link(__('New Customer', true), array('controller' => 'customers', 'action' => 'add')); ?> </li>
		<li><?php echo $html->link(__('List Payments', true), array('controller' => 'payments', 'action' => 'index')); ?> </li>
		<li><?php echo $html->link(__('New Payment', true), array('controller' => 'payments', 'action' => 'add')); ?> </li>
		<li><?php echo $html->link(__('List Transactions', true), array('controller' => 'transactions', 'action' => 'index')); ?> </li>
		<li><?php echo $html->link(__('New Transaction', true), array('controller' => 'transactions', 'action' => 'add')); ?> </li>
	<?php endif; ?>
	</ul>
</div>
